package com.example.demo.service;

import com.example.demo.mapper.BooksMapper;

import com.example.demo.pojo.Catrgoryicon;
import com.example.demo.pojo.Goodsaddguanli;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author yanglup
 * @create 2020-12-05 21:18
 */
@Service
public class BookServiceImpl implements BookService{
    @Autowired
    BooksMapper booksMapper;

    /**查询添加的图书*/
    @Override
    public PageInfo<Goodsaddguanli> Booklist(Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<Goodsaddguanli> mylistgoodsaddguanli= booksMapper.Booklist();
        PageInfo<Goodsaddguanli> goodsaddguanliPageInfo=new PageInfo<Goodsaddguanli>(mylistgoodsaddguanli,pageSize);
        return goodsaddguanliPageInfo;
    }
//    @Override
//    public List<Goodsaddguanli> Booklist() {
//        return booksMapper.Booklist();
//    }
    /**查询图书列表数*/
    @Override
    public Integer Booklistnumber() {
        return booksMapper.Booklistnumber();
    }

    /**添加图书*/
    @Override
    public void Bookaddtijiao(Integer cat_id, String goods_name, Integer goods_price, Integer goods_number, String school, String goods_oldnew, String goods_described, String goods_small_logo, String goods_small_logo2, String goods_small_logo3, Integer cat_one_id, Integer cat_two_id, String goods_serial, String openid, Integer status) {
        booksMapper.Bookaddtijiao(cat_id,goods_name,goods_price,goods_number,school,goods_oldnew,goods_described,
                goods_small_logo,goods_small_logo2,goods_small_logo3,cat_one_id,cat_two_id,goods_serial,openid,status);
    }

    /**修改1查询*/
    @Override
    public Goodsaddguanli Bookupdate(Integer goods_id) {
        return booksMapper.Bookupdate(goods_id);
    }
    /**修改2  更新*/
    @Override
    public void Bookupdatetijiao(Integer goods_idchuanru, Integer goods_id, Integer cat_id, String goods_name, Integer goods_price, Integer goods_number, String school, String goods_oldnew, String goods_described, String goods_small_logo, String goods_small_logo2, String goods_small_logo3, Integer cat_one_id, Integer cat_two_id, String openid, Integer status) {
        booksMapper.Bookupdatetijiao(goods_idchuanru,goods_id,cat_id,goods_name,goods_price,goods_number,school,goods_oldnew,goods_described,
                goods_small_logo,goods_small_logo2,goods_small_logo3,cat_one_id,cat_two_id,openid,status);
    }

    /**删除图书*/
    @Override
    public void Bookdelete(Integer goods_id) {
        booksMapper.Bookdelete(goods_id);
    }

    /**搜索图书*/
    @Override
    public List<Goodsaddguanli> Booksearch(String goods_name) {
        return booksMapper.Booksearch(goods_name);
    }

    /**搜索图书的数量*/
    @Override
    public Integer Booksearchnumber(String goods_name) {
        return booksMapper.Booksearchnumber(goods_name);
    }
}
